package com.tang.service.impl;

import com.tang.service.Image;

/**
 * 图片代理类
 *
 * @author fulin.tang
 * @version V3.0
 * @since 2021/9/15 17:56
 */
public class ProxyImage implements Image {
    
    private RealImage realImage;
    private final String fileName;

    public ProxyImage(String fileName) {
        this.fileName = fileName;
    }

    @Override
    public void display() {
        if (realImage == null) {
            synchronized (ProxyImage.class) {
                realImage = new RealImage(fileName);
            }
        }
        realImage.display();
    }
    
}
